<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
            <title>Cindy JS</title>
            <script type="text/javascript" src="../build/js/Cindy.js"></script>

            <link rel="stylesheet" href="../css/cindy.css">
            </head>

	<body style="font-family:Arial;">

        <h1>CindyJS: Convex Hull</h1>


        <script id='csmove' type='text/x-cindyscript'>
            pts=[A.xy,B.xy,C.xy,D.xy,E.xy,F.xy,G.xy,H.xy,I.xy,J.xy,K.xy,L.xy,M.xy,N.xy];
            pairs=pairs(pts);
            hull=select(pairs,s,
                  left=select(pts,area(#,s_1,s_2)>0.0001);
                  right=select(pts,area(#,s_1,s_2)<-0.0001);
                  length(left)*length(right)==0;
            );
            apply(hull,draw(#_1,#_2));
            </script>


        <div  id="CSCanvas" style="width:600px; height:600px; border:2px solid #000000"></div>

        <script type="text/javascript">

            var gslp=[
                      {name:"A", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"B", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"C", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"D", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"E", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"F", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"G", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"H", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"I", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"J", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"K", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"L", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"M", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      {name:"N", kind:"P", type:"Free", pos:[Math.random()*8-4,Math.random()*8-4,1]},
                      ];

            CindyJS({canvasname:"CSCanvas",
                        movescript:"csmove",
                        geometry:gslp});





            </script>



	</body>
</html>
